<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组的扩展</title>
</head>
<body>
<script type="text/javascript">
    let obj = {
        '0':'a',
        '1':'b',
        '2':'c',
        '3':'d',
        '4':'e',
        length: 5
    }
    let arr4 = Array.from(obj);//这里使用扩展运算符不行
    console.log(arr4);
    function test(){
        //ES5中将伪数组转为真正的数组
        let arr  = [].slice.call(arguments);
        console.log(arr);
        //ES6转换，数组增加的方法
        let arr2 = Array.from(arguments);
        //或者就使用扩展运算符
        let arr3 = [...arguments];
        console.log(arr2);
        console.log(arr3);
    }
    test(1,2,3,4);
    //of()
    let arr5 = Array.of(1,2,34,5);
    console.log(arr5);
    //copywithin
    let arr6 = [1,2,3,4,5,6].copyWithin(0,2);//[3,4,5,6,5,6]
    console.log(arr6);
    //find(),findIndex
    let arr7 = [1,23,4,-10,-9];
    console.log(arr7.find(val => val <= 0));
    console.log(arr7.findIndex(val => val <= 0));
    //entries() keys() values()
    let arr8 = [1,'3213','dfsa','wqe'];
    for ( let [index,val] of arr8.entries() ){
        console.log(index,val);
    }
    for (let key of arr8.keys()){
        console.log(key);
    }
    for (const val of arr8.values()) {
        console.log(val);
    }
    //includes()
    console.log(arr8.includes('3213'));
</script>
</body>
</html>